
<!--top结束-->
<script type="text/javascript" src="<?= base_url() ?>resource/js/layer/layer.js"></script>
<div class="mian">
    <div class="mian1">
        <div class="mian2">
            <!--left start-->
            <?php $this->load->view('defaults/common/left'); ?>
            <!--left end-->
            <!--right start-->
            <div class="right">
                <!--breadcrumb start-->
                <div class="righta"><?= $this->breadcrumb->generateHTML(); ?> </div>
                <!--breadcrumb end-->
                <!-- contents start -->
                <div id="contents">
                    <div id="contents_container">
                        <form id='zcsq_form' action="<?= blang_url('wms/InStock/zcsq_cg') ?>" method="post" name="myform" onsubmit="return myform_submit()" autocomplete="off" >
                            <table cellpadding="0" cellspacing="0" id="table_forms" border="1">
                                <tr>
                                    <td align="center" colspan="2" class="sub_padding_right">
                                        <button type="button" onclick="zcsq_cg()"  style="margin-right: 20px;width: 150px; height: 30px; margin-left: 200px;" >创建常规转储申请单</button>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="forms_left">仓库代码（出）:</td>
                                    <td>                                        <select  name="from_whs_code"  placeholder="from_whs_code">
                                           <?php foreach($whsCode as $oneWhs){?>
                                                  <option value ="<?=$oneWhs?>"><?=$oneWhs?></option>  
                                                                        <?php }?>
                                        </select></td>
                                </tr>
                                <tr>
                                    <td class="forms_left">仓库代码（入）:</td>
                                    <td>                                        <select  name="whs_code"  placeholder="whs_code">
                                           <?php foreach($whsCode as $oneWhs){?>
                                                  <option value ="<?=$oneWhs?>"><?=$oneWhs?></option>  
                                                                        <?php }?>
                                        </select></td>
                                </tr>
                                <tr>
                                    <td class="forms_left">转储类型:</td>
                                    <td>
                                        <select  id="in_out_type" name="in_out_type"  placeholder="in_out_type">
                                                <option value ="cgzc">常规转储</option>  
                                        </select></td>
                                </tr>
<!--                                <tr>
                                    <td class="forms_left" >SKU:</td>
                                    <td><input id="sku" type="text" name="sku" value=""/></td>
                                    <td class="forms_left"><?= lang('product_wlsl') ?>:</td>
                                    <td><input id="quantity" type="text" name="quantity" value=""  style="width: 50px"/></td>
                                    <td class="forms_left">订单号:</td>
                                    <td><input id="quantity" type="text" name="quantity" value="" /></td>
                                    <td><button type="button" onclick="stockin()"  style="margin-right: 20px;width: 150px; height: 30px; margin-left: 200px;" >添加</button></td>
                                    
                                </tr>-->
                                <tr>
                                    <td class="forms_left">转储备注:</td>
                                    <td><textarea rows="1" cols="50" id="comments" name="comments" value=""></textarea></td>
                                </tr>
                                <tr>
                                    <td class="forms_left">产品:</td><td>
                                        <input id="sku1" type="text" name="sku1" placeholder="输入SKU号" value=""/>
                                        <input id="qty1" type="text" placeholder="输入产品数量" name="qty1"  value=""/>
                                        <button id="add_row_bt" class="1" type="button" onclick="add_row(1)" >添加栏位</button></td>
                                </tr>
                            </table>
                        </form>
                    </div>
                </div>
                <!-- contents end -->
            </div>
            <!--right end-->
            <div class="clear"></div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(window).load(function() {
        $("#sku").focus();
    }); 
    $('#sku').bind('keypress', function (event) {
        if (event.keyCode == "13") {
            $("#quantity").focus();
        }
    });
    //    $('#quantity').bind('keypress', function (event) {
    //        if (event.keyCode == "13") {
    ////            zcsq_in()
    //        }
    //    });
    function zcsq_cg(){
        //loading层
        var LDindex;
        var dataParam = $("#zcsq_form").serializeArray();
        var index_num=$('#add_row_bt').attr("class");
        dataParam.push({"name":"index","value":index_num})
        $.ajax({
            type:'post',
            timeout:60000,
            data:dataParam,
            url:"<?= blang_url('wms/InStock/zcsq_cg') ?>",
            beforeSend:function(XMLHttpRequest){
                LDindex = layer.load(1, {
                    shade: [0.1,'#fff'] //0.1透明度的白色背景
                })
            }, 
            success: function (rs) {
                layer.close(LDindex); 
                obj=JSON.parse(rs);
                if(true==obj.success){
                    window.location.href='/sc/wms/Zcsq/detail/'+obj.id;
                }
                else{
                    alert(obj.msg);
                }
            },
            error: function (e, jqxhr, settings, exception) {

            },
            complete : function(XMLHttpRequest,status){
                layer.close(LDindex); 
                if(status=='timeout'){
                    alert("Request timed out,Please try again!");
                }
            }
        });
    }
    function add_row(index){
        index++;
        $("#add_row_bt").replaceWith("<button id='add_row_bt' class='"+index+"' type='button' onclick='add_row("+index+")' >添加栏位</button>");
        $input_sku_str="<tr id='sku_tr_"+index+"'><td class='forms_left'>产品:</td><td><input id='sku"+index+"' type='text' name='sku"+index+"' placeholder='输入SKU号' value=''/><input id='qty"+index+"' type='text' placeholder='输入产品数量' name='qty"+index+"'  value=''/><button id='delete_tr_bt' type='button' onclick='delete_tr(\"#sku_tr_"+index+"\","+index+")' >删除栏位</button></td></tr>";
        $("#table_forms").append($input_sku_str);
    }
    function delete_tr(id,index){
        $(id).remove();
    }
</script>
